package com.edmond.jyframe.fragments;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.edmond.jyframe.R;
import com.edmond.jyframe.adapter.HomeAdapter;
import com.edmond.jyframe.classes.GoodsItem;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by edmond on 17-4-27.
 */

public class ShowOneFragment extends Fragment {
    private View view;

    private HomeAdapter homeAdapter;

    private RecyclerView recyclerView;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        view = inflater.inflate(R.layout.fragment_show_one,container,false);

        List<GoodsItem> data = new ArrayList<>();

        data.add(new GoodsItem());
        data.add(new GoodsItem());
        data.add(new GoodsItem());
        data.add(new GoodsItem());
        data.add(new GoodsItem());
        data.add(new GoodsItem());
        data.add(new GoodsItem());
        data.add(new GoodsItem());
        data.add(new GoodsItem());
        data.add(new GoodsItem());

        homeAdapter = new HomeAdapter(getActivity(),data);

        recyclerView = (RecyclerView) view.findViewById(R.id.recycler_view);
        recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
        recyclerView.setAdapter(homeAdapter);

        homeAdapter.setOnItemClickListener(new HomeAdapter.OnItemClickListener() {
            @Override
            public void onItemClick(View view, String goodsid, int position) {

            }

            @Override
            public void onItemLongClick(View view, String goodsid, int position) {

            }
        });

        return view;
    }
}
